<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>物资入库记录</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <input type="hidden" value="${id}" id="inId">
    <div class="panel panel-info">
        <div class="panel-body" id="pop">

        </div>
    </div><!-- /.panel -->
</div><!--/#main-container-->

<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script src="${res}/static/plugin/pdfjs/pdf.js" type="text/javascript"></script>
<script type="text/javascript">
     $(document).ready(function(e) {
         var inId = $("#inId").val();
         vm.showPdf(inId);
     });
     var vm = this;
     //展示pdf文档
     vm.showPdf = function(inId){
         vm.url = '${res}/file/'+inId+'-signed.pdf';
         PDFJS.workerSrc = '${res}/static/plugin/pdfjs/pdf.worker.js';
         PDFJS.getDocument(vm.url).then(function getPdfHelloWorld(pdf) {
             vm.pdf = pdf;
             for (var i = 1; i <= pdf.numPages; i++) {
                 var id = "canvas"+i;
                 var html = "<canvas id='"+id+"' pagenum='"+i+"'></canvas>"
                 $("#pop").append(html);
                 vm.show(i);
             }
         });
     }
     vm.show = function(i){
         vm.pdf.getPage(i).then(function getPageHelloWorld(page) {
             var scale = 1.5;
             var viewport = page.getViewport(scale);
             var id = "canvas"+i;
             var canvas = document.getElementById(id);
             var context = canvas.getContext('2d');
             canvas.height = viewport.height-2;
             canvas.width = viewport.width-2;
             var renderContext = {
                 canvasContext: context,
                 viewport: viewport
             };
             page.render(renderContext);
         });
     }
</script>
<!-- script end -->
</body>
</html>
